package filters;

import interfaces.IMap;

public class ModaFilter implements IFilter
{
	int Histogram[];
	public ModaFilter()
	{
		Histogram = new int[256];		
	}
	@Override
	public int ApplyFilter(int Px, int Py, IMap map) 
	{
		for(int i=0;i<256;i++)
			Histogram[i]=0;
		
		for (int y = -3; y < 4; y++)
            for (int x = -3; x < 4; x++)
            {            	
            	int C = (int)map.Get(Px + x,Py + y);
            	Histogram[C]++;            	
            }
		
		int max=0;
		for(int i=0;i<256;i++)
		{
			if(max<Histogram[i])
				max=Histogram[i];
		}
		return max;
	}	
}
